package hamaster.jpbc.util;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;

public final class SwingUtil {

	public static void setLocationCenter(Component comp, Component parent) {
		// TODO 实现这个方法
	}

	public static void setLocationCenter(Component comp) {
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension frameSize = comp.getSize();
		if (frameSize.height > screenSize.height)
			frameSize.height = screenSize.height;
		if (frameSize.width > screenSize.width)
			frameSize.width = screenSize.width;
		int height = (screenSize.height - frameSize.height) / 2;
		int width = (screenSize.width - frameSize.width) / 2;
		comp.setLocation(width, height);
	}
}
